package com.zz.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import com.zz.employeedaoimpl.EmployeeDaoImpl;
import com.zz.personmodel.Employee;

@Service
public class EmployeeService {
	@Autowired
	private EmployeeDaoImpl employeedao;
	@Transactional
	public void addEmployee(@RequestParam(value = "identity_number", required = false) String identity_number,
	@RequestParam(value = "person_name", required = false) String person_name,
	@RequestParam(value = "birth_time", required = false) String birth_time,
	@RequestParam(value = "sex") String sex,
	@RequestParam(value = "matital_status") String matital_status,
	@RequestParam(value = "spouse_name") String spouse_name) {
		employeedao.addEmployee(identity_number, person_name, birth_time, sex, matital_status, spouse_name);
	}
	@Transactional
	public List<Employee> findpersonList(
			@RequestParam(value = "identity_number", required = false) String identity_number,
			@RequestParam(value = "person_name", required = false)String person_name,
			@RequestParam(value = "birth_time", required = false)String birth_time,
			@RequestParam(value = "gender", required = false)String gender,
			@RequestParam(value = "page", required = false) Integer page) {
		return employeedao.findEmployee(identity_number, person_name, birth_time, gender,page);
	}
	@Transactional
	public void deletemployee(@RequestParam(value="id")int id) {
		employeedao.deletEmployee(id);
	}
	public void updateemployee(@RequestParam(value="id",required=false) int id,@RequestParam(value = "identity_number", required = false) String identity_number,
			@RequestParam(value = "person_name", required = false) String person_name,
			@RequestParam(value = "birth_time", required = false) String birth_time,
			@RequestParam(value = "sex") String sex, @RequestParam(value = "matital_status") String matital_status,
			@RequestParam(value = "spouse_name") String spouse_name){
		employeedao.updateEmployee(id,identity_number, person_name, birth_time, sex, matital_status, spouse_name);
	}
}
